const {
  baseUrl,
  getRequest,
  postRequest
} = require("../../../utils/request.js")
const {
  mock_flag,
  login_flag
} = require("../../../data/index.js")
Page({
  data: {
    //用户id
    userId: 0,
    // 用户类型，1表示学生，2 表示维修工
    userType: '',
    //学生功能
    studentFunctionList: [{
        icon: 'success_no_circle',
        text: '维修报备',
        tap: 'to_repairReport_add',
      },
      {
        icon: 'search',
        text: '维修查询',
        tap: 'to_repairReport_search',
      },
      {
        icon: 'success',
        text: '维修记录',
        tap: 'to_repairReport_record',
      },
      {
        icon: 'info',
        text: '联系我们',
        tap: 'to_feedback_add',
      },
    ],
    //维修工功能
    maintainerFunctionList: [{
        icon: 'info',
        text: '维修任务',
        tap: 'to_task',
      },
      {
        icon: 'search',
        text: '我的任务',
        tap: 'to_myTask',
      }
    ],
  },
  onLoad(options) {
    //登录拦截
    const isLogin = wx.getStorageSync('isLogin');
    if (!isLogin) {
      wx.showToast({
        title: '请先登录',
        icon: 'none'
      });
      if (login_flag) {
        wx.redirectTo({
          url: '/pages/user/wxlogin/wxlogin'
        });
      }
      if (!login_flag) {
        wx.redirectTo({
          url: '/pages/user/login/login'
        });
      }
    }
    //初始化数据
    this.setData({
      userId: wx.getStorageSync('userId'), //获取用户id
      userType: wx.getStorageSync('userType'), //获取用户类型
    })
    //mock数据
    if (mock_flag) {
      this.setData({

      })
    }
    //网络请求
    if (!mock_flag) {

    }
  },
  /**
   * 学生功能
   */
  // 维修报备
  to_repairReport_add() {
    wx.navigateTo({
      url: '/pages/work/repairReport_add/repairReport_add',
    })
  },
  // 维修查询
  to_repairReport_search() {
    wx.navigateTo({
      url: '/pages/work/repairReport_search/repairReport_search',
    })
  },
  // 维修记录
  to_repairReport_record() {
    wx.navigateTo({
      url: '/pages/work/repairReport_record/repairReport_record',
    })
  },
  // 联系我们
  to_feedback_add() {
    wx.navigateTo({
      url: '/pages/work/feedback/feedback',
    })
  },
  /**
   * 维修工功能
   */
  to_task() {
    wx.navigateTo({
      url: '/pages/work/task/task',
    })
  },
  to_myTask() {
    wx.navigateTo({
      url: '/pages/work/myTask/myTask',
    })
  },
})